<!--
* @Author       : 李江涛
* @Description  : 
-->

<template>
  <Form ref="FormRef" :formSchema="formSchema"></Form>
  <el-button type="primary" @click="click">提交</el-button>
</template>
<script lang="ts">
export default {name: 'Home'};
</script>

<script lang="ts" setup>
import {ref} from 'vue';
import Form from '@/components/Form/Index.vue';
import {IFormSchema} from '@/components/Form/type';

const FormRef = ref<InstanceType<typeof Form>>();
const formSchema = ref<IFormSchema>({
  text: {
    type: 'Text',
    label: '文本框',
    value: ''
  },
  aa: {
    type: 'Number',
    label: '数字',
    value: ''
  },
  bb: {
    type: 'SelectLabelPosition',
    label: '下拉框',
    value: ''
  },
  cc: {
    type: 'Textarea',
    label: '文本域',
    value: ''
  },
  dd: {
    type: 'Day',
    label: '日期',
    value: ''
  },
  ee: {
    type: 'UploadFile',
    label: '文件',
    value: [],
    style: 'width: 100%;'
  },
  ff: {
    type: 'UploadImg',
    label: '图片',
    value: [],
    style: 'width: 100%;'
  }
});

const click = async () => {
  const body = await FormRef.value?.getValue();

  console.log('[ body ] ==>', body);
};
</script>

<style lang="scss" scoped></style>
